import request from '@/utils/request'

// 查询一日一练记录列表
export function listPractice(query) {
  return request({
    url: '/hyg/practice/list',
    method: 'get',
    params: query
  })
}

// 查询用户练习记录
export function getUserPractice(userId) {
  return request({
    url: '/hyg/practice/user/' + userId,
    method: 'get'
  })
}

// 查询用户总刷题数
export function getTotalQuestions(userId) {
  return request({
    url: '/hyg/practice/user/' + userId + '/totalQuestions',
    method: 'get'
  })
}

// 查询一日一练记录详细
export function getPractice(id) {
  return request({
    url: '/hyg/practice/' + id,
    method: 'get'
  })
}

// 新增一日一练记录
export function addPractice(data) {
  return request({
    url: '/hyg/practice',
    method: 'post',
    data: data
  })
}

// 修改一日一练记录
export function updatePractice(data) {
  return request({
    url: '/hyg/practice',
    method: 'put',
    data: data
  })
}

// 删除一日一练记录
export function delPractice(id) {
  return request({
    url: '/hyg/practice/' + id,
    method: 'delete'
  })
}

// 导出一日一练记录
export function exportPractice(query) {
  return request({
    url: '/hyg/practice/export',
    method: 'get',
    params: query
  })
}
// 处理每日排名和奖励
export function processRanking(practiceDate) {
  return request({
    url: '/hyg/practice/processRanking',
    method: 'post',
    params: { practiceDate }
  })
}

// 获取每日排名
export function getDailyRanking(practiceDate) {
  return request({
    url: '/hyg/practice/ranking',
    method: 'get',
    params: { practiceDate }
  })
}
